//
//  BaseTableViewController.swift
//  YYWeiBo
//
//  Created by 崔洋洋 on 15/10/8.
//  Copyright © 2015年 崔洋洋. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate{

    // 用户登记标记
    var userLogin = false
    // 访客登录视图
    var VisitorView: VisitorLoginView?
    
    override func loadView() {
         // 根据是否登录,替换根视图
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    private func setupVisitorView() {
        
        VisitorView = VisitorLoginView()
        VisitorView?.delegate = self
        view = VisitorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
    }
    
    // MARK: -VisitorLoginViewDelegate
  
    func visitorLoginViewWillRegister() {
            
        print("注册")
    }
    
    func visitorLoginViewWillLogin() {
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
    }
}
